@include('admin.public.head')

<style type="text/css">

    .inner_btn {
        background: #19a97b;
        color: white;
        padding: 5px 8px;
        border-radius: 2px;
    }

</style>

<div class="ibox-title">
    <h5>签到用户管理</h5>
</div>

<div class="ibox-content">
    <div class="row">
        <div class="col-sm-12 pull-right m-b-xs">
            <form action="">
                <div class="col-sm-1  m-b-xs text-center pull-right">
                    <button type="submit" class="btn btn-sm btn-primary">搜索</button> </span>
                </div>

                <div class="col-sm-2 text-center pull-right">
                    <input type="text" name="sear_value" value="{{$sear_value}}" placeholder="姓名/手機號/昵稱/用戶id" class="input form-control">
                </div>

            </form>
        </div>
    </div>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>姓名</th>
            <th>用戶編號</th>
            <th>用戶頭像</th>
            <th>用戶等级</th>
            <th>用戶昵稱</th>
            <th>手機號</th>
            <th>訓練時長(分鐘)</th>
            <th>積分</th>
            <th>編輯</th>
        </tr>
        </thead>
        <tbody>
            @foreach ($result as $k=>$v)
                <tr>
                    <td>
                        {{$v->name}}
                    </td>
                    <td>
                        {{$v->user_number}}
                    </td>
                    <td>
                        <img src="{{$v->head_img}}" width="300" height="150">
                    </td>
                    <td>
                        {{$v->user_level->rank_name??''}}
                    </td>
                    <td>
                        {{$v->nickname??''}}
                    </td>
                    <td>{{$v->phone}}</td>
                    <td>{{$v->total_train_time??''}}</td>
                    <td>{{$v->total_integral??''}}</td>
                    <td>
                        <a  class="btn btn-primary btn-sm dropdown-toggle" url="/class_sign_in/{{$class_bass_info_id}}/{{$v->id}}/{{$time}}" onclick="save_time($(this))" href="javascript:void(0)">簽到
                        </a>&nbsp;&nbsp;
                    </td>
                </tr>
            @endforeach
            {{ $result->appends(Request::except ('page'))->links() }}
        </tbody>
        {{ $result->appends(Request::except ('page'))->links() }}
    </table>
</div>
<script>
    function save_time(obj){
        var url = obj.attr('url');
        var title =  "你確定签到";
        var botton =  "签到";
        var result =  "签到成功";

        swal({
            title: title,
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: botton,
            closeOnConfirm: false
        }, function () {
            $.ajax({
                type: "post",
                url: url,
                dataType: "json",
                success: function(data) {

                    var swal_json = {
                        title : result,
                        type : "success"
                    }

                    swal(swal_json,function(isConfirm){
                        window.location.reload();
                    });

                }
            });

        });
    }

</script>
